from __future__ import with_statement
from kuai.strtool import *
from kuai.iotool import *
from kuai.ff import *

class ForceFieldReader(Reader):
    pass

def read_ff(file, type = None):
    if type is None:
        type = extname(file)
    ppffilename = file
    eqtfilename = file[:-4]+".eqt"
    
    file = open(ppffilename)
    from kuai.dff.dffppf import reader
    ff = reader.read(file)
    file.close()
    try:
        file = open(eqtfilename)
        eqt = EquivalenceTable.read(file)
        file.close()
    except:
        eqt = EquivalenceTable()
    return (ff, eqt, )

def parse_ff(data, type):
    file = StringIO(data)
    return None

class ForceFieldWriter(Writer):
    pass



def write_ff(file, ff, type=None):
    if type is None:
        type = extname(file)
    from kuai.dff.dffmsd import writer    
    with open(file, "w") as file: 
        result = writer.write(file, ff)
        file.close()
        return True
